<?php
include "includes/ui.php";
include "controls/register_detail_db.php";

echo headerHTML("service"," ลงทะเบียนใช้บริการ");

$m_db = new M_Register_Detail();
$m_year = $_POST['m_year'];
$m_term = $_POST['m_term'];
$m_id = $_POST['m_id'];
$m_flag = $_POST['m_flag'];
$disable = $m_flag==0?"disabled":"";
$student_val = $m_db->getUserInfo($m_id, $m_year);
?> 
<input type='hidden' name='m_id' id='m_id' value='<?php echo $m_id;?>'/>
 <div id="popupSave" class="modal hide fade" style="width:350px;top:35% !important;margin-left:-180px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-header" style='padding-top:20px;padding-bottom:25px;'>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel" style="color:#72a9c9;"><img src='img/info1.png' width='24px'/> คุณต้องการบันทึกข้อมูล ?</h3>
    </div>
  
    <div class="modal-footer center" style="text-align:center !important;padding-top:15px;padding-bottom:15px;">
        <button type='button'  class="btn btn-primary" id="btnSave">ตกลง</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
    </div>
 
</div> 
<!-- Live Stats -->
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span12">
 <form class="form-horizontal" id='frmBack' method="POST" action="unregister.php" style='margin-bottom:0px;padding-bottom:0px;'>
        <!--  : Top Bar -->
        <div class="top-bar">
			<?php if ($m_flag==0){?>
            <h3><i class="icon-user"></i> ลงทะเบียนใช้บริการ</h3>
			<?php } else { ?>
			<h3><i class="icon-user"></i> ยกเลิกใช้บริการ</h3>
			<?php }?>
           <div class='tmp' style='float:right'>
				<a href="#popupSave" data-toggle="modal" ><button class="btn btn-primary" type='button' tooltip="Add">บันทึก</button></a>
				 
				 <a href="unregister.php"  ><button class="btn btn-danger" type='button' tooltip="Add">กลับ</button></a>
			 
              
            </div>
		
        </div>
 </form>
        <!-- /  : Top Bar -->



        <!-- Pie: Content -->
        <div class="well no-padding" style='height:130px;' >
			<div class="span12">
				<div class="row-fluid">
				 <form class="form-horizontal">
					<div class='span12'>
					 <div class="control-group">
								<label class="control-label" style='margin-top:0px;padding-top:0px;' for="inputName"><i class="icon-double-angle-right"></i> ปีการศึกษา :</label>
								<div class="controls">
									<span class="help-inline" style=""> <?php echo $m_year;?> / <?php echo $m_term;?></span>
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;margin-left:50px;"> ระดับชั้น :</span>
									&nbsp; <span class="help-inline" style=""> <?php echo $student_val['class_name'] ." / ".$student_val['room'] ?></span>
									
									
								</div>
					 </div>
					 
					  <div class="control-group" >
						<label class="control-label"  style='margin-top:0px;padding-top:0px;' for="inputName"><i class="icon-double-angle-right"> </i> รหัสนักเรียน :</label>
						<div class="controls">
							<span class="help-inline" style=""><?php echo $student_val['code'];?></span>
							&nbsp;<span class="help-inline" style="font-weight:bold;margin-left:50px;">ชื่อ - นามสกุล :</span>
							&nbsp;&nbsp; <span class="help-inline" style=""><?php echo $student_val['title_name']. ' '. $student_val['thai_name']. ' '. $student_val['thai_surname'];?></span>
							&nbsp;<span class="help-inline" style="font-weight:bold;margin-left:50px;">ชื่อ เล่น :</span>
							&nbsp;&nbsp; <span class="help-inline" style=""> <?php echo $student_val['thai_nickname'];?></span>
						</div>
					 </div>
			 
					</div>
					</form>
				</div>
			</div>
        </div>
        <!-- / Pie: Content -->

    </div>
    <!-- / Pie -->

</div>
 <form class="list-widget" id="pagination-todo">
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span6">

        <!--  : Top Bar -->
        <div class="top-bar">
            <h3><i class="icon-calendar"></i> คอร์สเสริมทักษะ</h3>
         </div>
        <!-- /  : Top Bar -->
        <!-- Pie: Content -->
        <div class="well no-padding" >
		<?php
			
			$result=$m_db->load_course($m_year,$m_term,$m_id );
			if ($m_db->getRowCount()>0){
			$check="";
			 while($row = $result->FetchRow()){
			  $check= $row['isSelect']==0?"":"checked";
		?>
			<div class="item" style="display: block;padding-bottom:10px;">
				<label class="checkbox">
					<div class="row-fluid">
					<input type="checkbox" name='course' value='<?php echo $row['id'];?>'  <?php echo $check.' '.$disable;?> >  <?php echo $row['detail'];?>
					<small class="pull-right" style='color:orange;'><?php echo number_format($row['cost'],0,'',',').'/'.$row['cost_type'];?></small>
					</div>
					<?php 
						$result2=$m_db->load_course_detail($row['id']);
						$html1="";
						$html2="";
						$class_list="";
						$date_list="";
						while($row2 = $result2->FetchRow()){
							$class_list = $m_db->getClasslist($row2['for_class']);
							$date_list = $m_db->getDate($row2['study_date']);
							$html1.="<tr><td style='text-align:left;'><span style='display:block;' class='help-inline'>".$class_list ."</span></td>";
							$html1.="<td style='text-align:center;'><span style='display:block;' class='help-inline'>".$date_list ."</span></td>";
							$html1.="<td style='text-align:right;'><span style='display:block;' class='help-inline'>".$row2['study_time'].'-'.$row2['study_time_end'].' น.'."</span></td></tr>";
						}
					?>
					<div class="row-fluid" style='margin-top:10px;'>
						<table class='table' width="100%">
							<?php echo $html1;?>
						</table>
						
					</div>
				</label>
			</div>
		 <?php 
			}
			}
		 ?>
		</div>
						<!-- / Todo List: Pagination Content -->
					 
     </div>
    <!-- / Pie: Content -->
    <!-- / Pie -->

	 <!-- Pie: Box -->
    <div class="span6">

        <!--  : Top Bar -->
        <div class="top-bar">
            <h3><i class="icon-truck"></i> รถโรงเรียน</h3>
 
        </div>
        <!-- /  : Top Bar -->
        <!-- Pie: Content -->
        <div class="well no-padding" >
		<!-- Todo List: Item -->
			<?php	
				$result=$m_db->load_bus($m_year,$m_term,$m_id);
				if ($m_db->getRowCount()>0){
					$check="";
					$lock ="";
					while($row_bus=$result->FetchRow()){
						$check= $row_bus['isSelect']==0?"":"checked";
						if ( $row_bus['cnt']!=0)
							$lock=$disable;
							
						$result_bus_detail = $m_db->load_bus_detail($row_bus['id']);
						$html="";
						while($row_bus_detail = $result_bus_detail->FetchRow()){
							$html.="".$row_bus_detail['route']."<br/>";
						}
			?>
			<div class="item" style="display: block;">
				<label class="radio" <?php echo $lock;?>>
					<input type="radio" name='bus' value='<?php echo $row_bus['id'];?>' <?php echo $check;?> <?php echo $lock;?>>  <?php echo $row_bus['detail'];?>
					<small class="pull-right" style='color:orange;'><?php echo number_format($row_bus['cost'],0,'',',') ."/". $row_bus['cost_type']; ?></small>
					<p style='padding:0px; padding-top:10px padding-left:10px;margin:5px 0 0 0;'><b>เส้นทาง</b> 
					<?php echo $html;?>
					</p>
				</label>
			</div>
			<?php
			}
			?>
				<div class="item" style="display: block;">
			<label class="radio">
				<input type="radio" name='bus' id='bus_0' value='0'  />ไม่ใช้บริการ
				<small class="pull-right" style='color:orange;'> </small>
				<p style='padding:0px; padding-top:10px padding-left:10px;margin:5px 0 0 0;'><b></b> 
				 
				</p>
			</label>
			</div>
			<?php 
			}
			?>
			
			<!-- / Todo List: Item -->
		</div>
						<!-- / Todo List: Pagination Content -->
					 
				  
	</div>
			 
        <!-- / Pie: Content -->

    </div>
 </form>
    <!-- / Pie -->
</div>
<!-- / Live Stats -->

<?php
echo footerHTML();
?>

<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src='js/jquery.hotkeys.js'></script>
<!--script src='js/fullcalendar.min.js'></script-->
<script src="js/jquery-ui-1.10.2.custom.min.js"></script>
<script src="js/jquery.pajinate.js"></script>
<!--script src="js/jquery.prism.min.js"></script-->
<script src="js/jquery.dataTables.min.js"></script>

<script src="js/jquery.flot.resize.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-wysiwyg.js"></script>
<!--script src="js/bootstrap-typeahead.js"></script-->
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/avocado-custom.js"></script>
<script src="js/myScript/js_other_register_detail.js"></script>


</html>